<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
 <script src="js/cookie_util.js"></script>
     <script type="text/javascript">
    	var user_id=getCookie("userId");
		console.log(user_id);
    	if(user_id!=null){//用户ID存在
				function add(){
					var trouble_code=$("#trouble_code").val();
					var trouble_name=$("#trouble_name").val();
					var trouble_remark=$("#trouble_remark").val();
					$.ajax({
						url:"http://localhost:8080/troubleinfo/add.do",
						type:"post",
						data:{"trouble_code":trouble_code,
							"trouble_name":trouble_name,
							"trouble_remark":trouble_remark},
						dataType:"json",
						success:function(rs){
							console.log("故障信息添加");
							alert(rs.msg);
							window.location.href="list.html";
						},
						error:function(){
							alert("故障信息添加成功");
						}
					})
			};
		}else{//用户ID不存在
			top.location.href="login.html";
		}
    </script>  
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>故障信息</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="">  
      <div class="form-group">
        <div class="label">
          <label>故障码：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" id="trouble_code"  />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>故障名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" id="trouble_name" />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>描述：</label>
        </div>
        <div class="field">
          <textarea id="trouble_remark" class="input w50" style="height:120px;"></textarea>
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button onclick="add()"  class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
</body></html>